this.BX=this.BX||{};this.BX.Landing=this.BX.Landing||{};this.BX.Landing.UI=this.BX.Landing.UI||{};(function(e,t,a,i,r,n){"use strict";var o,d,l,s,c,u,f,h,p;function g(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,i)}return a}function y(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?g(Object(a),!0).forEach((function(t){babelHelpers.defineProperty(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):g(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}var b=function(e){babelHelpers.inherits(t,e);function t(){var e;var a=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};babelHelpers.classCallCheck(this,t);e=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,a));e.setEventNamespace("BX.Landing.UI.Form.BaseForm");e.data=y({},a);e.options=e.data;e.id=Reflect.has(e.data,"id")?e.data.id:i.Text.getRandom();e.selector=Reflect.has(e.data,"selector")?e.data.selector:"";e.title=Reflect.has(e.data,"title")?e.data.title:"";e.label=Reflect.has(e.data,"label")?e.data.label:"";e.type=Reflect.has(e.data,"type")?e.data.type:"content";e.code=Reflect.has(e.data,"code")?e.data.code:"";e.descriptionText=Reflect.has(e.data,"description")?e.data.description:"";e.serializeModifier=e.options.serializeModifier||function(e){return e};e.headerCheckbox=e.data.headerCheckbox;e.cache=new i.Cache.MemoryCache;e.fields=new BX.Landing.Collection.BaseCollection;e.cards=new BX.Landing.Collection.BaseCollection;e.layout=t.createLayout();e.header=t.createHeader();e.body=t.createBody();e.footer=t.createFooter();i.Dom.append(e.header,e.layout);if(e.descriptionText!==null){e.description=t.createDescription();i.Dom.append(e.description,e.layout)}i.Dom.append(e.body,e.layout);i.Dom.append(e.footer,e.layout);if(i.Type.isString(e.title)&&e.title!==""){i.Dom.append(document.createTextNode(e.title),e.header)}if(i.Type.isString(e.descriptionText)&&e.descriptionText!==""){e.description.innerHTML=e.descriptionText}if(i.Type.isArray(e.data.fields)&&e.data.fields.length>0){e.data.fields.forEach((function(t){e.addField(t)}))}var r=n.Env.getInstance().getOptions(),o=r.sources;if(i.Type.isPlainObject(e.headerCheckbox)&&i.Type.isArray(o)&&o.length>0){i.Dom.append(e.getHeaderCheckbox(),e.header)}if(e.options.hidden===true){e.hide()}return e}babelHelpers.createClass(t,[{key:"show",value:function e(){i.Dom.attr(this.getLayout(),"hidden",null)}},{key:"hide",value:function e(){i.Dom.attr(this.getLayout(),"hidden",true)}},{key:"getLayout",value:function e(){return this.layout}},{key:"getHeaderCheckbox",value:function e(){var t=this;return this.cache.remember("headerCheckbox",(function(){var e=i.Text.getRandom();var a=t.headerCheckbox,r=a.text,n=a.help,c=a.state,u=a.onChange;var f=i.Tag.render(o||(o=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<input type="checkbox" id="','" class="landing-ui-form-header-checkbox-input">\n\t\t\t'])),e);var h=i.Tag.render(d||(d=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<label for="','" class="landing-ui-form-header-checkbox-label">',"</label>\n\t\t\t"])),e,r);var p=i.Tag.render(l||(l=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div class="landing-ui-form-header-checkbox">',"","</div>\n\t\t\t"])),f,h);if(i.Text.toBoolean(c)){f.setAttribute("checked",true)}if(i.Type.isFunction(u)){i.Event.bind(f,"change",(function(){u({state:f.checked===true,form:t})}))}if(i.Type.isString(n)&&n!==""){var g=i.Tag.render(s||(s=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t\t<a href="','" class="landing-ui-form-header-checkbox-help" target="_blank"> </a>\n\t\t\t\t'])),n);i.Dom.append(g,p)}return p}))}},{key:"getHeader",value:function e(){return this.header}},{key:"getBody",value:function e(){return this.body}},{key:"getFooter",value:function e(){return this.footer}},{key:"getNode",value:function e(){return this.layout}},{key:"addField",value:function e(t){if(i.Type.isObject(t)){this.fields.add(t);i.Dom.append(t.getNode(),this.getBody())}}},{key:"addCard",value:function e(t){var a=this;if(i.Type.isObject(t)){this.cards.add(t);t.fields.forEach((function(e){a.fields.add(e)}));i.Dom.append(t.getNode(),this.getBody())}}},{key:"removeCard",value:function e(t){var a=this;if(i.Type.isObject(t)){t.fields.forEach((function(e){a.fields.remove(e)}));this.cards.remove(t);i.Dom.remove(t.layout)}}},{key:"replaceCard",value:function e(t,a){this.removeCard(t);this.addCard(a)}},{key:"replaceField",value:function e(t,a){if(i.Type.isObject(t)&&i.Type.isObject(a)){i.Dom.replace(t.getNode(),a.getNode());this.fields.remove(t);this.fields.add(a)}}},{key:"isCheckboxChecked",value:function e(){var t=this.header.querySelector("input");return i.Type.isDomNode(t)&&t.checked}},{key:"clone",value:function e(t){var a=new this.constructor(i.Runtime.clone(t||this.data));this.fields.forEach((function(e){if(e instanceof BX.Landing.UI.Field.Date){var t=i.Runtime.clone(e.data);t.selector=a.selector;a.addField(e.clone(t));return}a.addField(e.clone())}));return a}},{key:"serialize",value:function e(){return this.serializeModifier(this.fields.reduce((function(e,t){if(i.Type.isFunction(t.getValue)){e[t.selector]=t.getValue()}return e}),{}))}},{key:"removeField",value:function e(t){this.fields.remove(t);i.Dom.remove(t.layout)}},{key:"disable",value:function e(){i.Dom.addClass(this.getLayout(),"landing-ui-disabled")}},{key:"enable",value:function e(){i.Dom.removeClass(this.getLayout(),"landing-ui-disabled")}}],[{key:"createLayout",value:function e(){return i.Tag.render(c||(c=babelHelpers.taggedTemplateLiteral(['<div class="landing-ui-form"></div>'])))}},{key:"createHeader",value:function e(){return i.Tag.render(u||(u=babelHelpers.taggedTemplateLiteral(['<div class="landing-ui-form-header"></div>'])))}},{key:"createDescription",value:function e(){return i.Tag.render(f||(f=babelHelpers.taggedTemplateLiteral(['<div class="landing-ui-form-description"></div>'])))}},{key:"createBody",value:function e(){return i.Tag.render(h||(h=babelHelpers.taggedTemplateLiteral(['<div class="landing-ui-form-body"></div>'])))}},{key:"createFooter",value:function e(){return i.Tag.render(p||(p=babelHelpers.taggedTemplateLiteral(['<div class="landing-ui-form-footer"></div>'])))}}]);return t}(r.EventEmitter);e.BaseForm=b})(this.BX.Landing.UI.Form=this.BX.Landing.UI.Form||{},BX,BX,BX,BX.Event,BX.Landing);
//# sourceMappingURL=baseform.bundle.map.js